const { httpsRequest } = require('./src/utils/http')


const params = {
  host: '1316704400-hlae7ercsd-gz.scf.tencentcs.com',
  method: 'post',
  path: '/aaa.mp3?age=555&p=9',
  headers: {
    authorization: '66666666'
  }
}
const post = {
  user: 'role',
  system: '888'
}
httpsRequest(params,post).then(data => {
  console.log(data)
  // response(res, textData, 200, '请求成功', array) //响应
}).catch(err => {
  console.log(err)
  // response(res, textData, 403, err.toString(), {})
})

// const params = {
//   host: 'chatgpt.indexls.com',
//   method: 'get',
//   path: '/hot_issues.txt'
// }
// httpsRequest(params).then(data => {
//   console.log(JSON.parse(data))
// }).catch(err => {
//   console.log(err)
// })

return



// 微信支付sdk接口
const { Wechatpay } = require('wechatpay-axios-plugin');
const { randomCode } = require("./src/utils/other");
// const { httpsRequest } = require('./src/utils/http');
// 商户号，支持「普通商户/特约商户」或「服务商商户」
const mchid = 'xx';
const appid = 'xxx' //微信APPID
// 「商户API证书」的「证书序列号」
const merchantCertificateSerial = 'xxx';
// 从本地文件中加载「商户API私钥」
const merchantPrivateKeyFilePath = './src/wechat/apiclient_key.pem';
const merchantPrivateKeyInstance = readFileSync(merchantPrivateKeyFilePath);
// 「微信支付平台证书」的「证书序列号」，下载器下载后有提示`serial`序列号字段
const platformCertificateSerial = '123456';
// 从本地文件中加载「微信支付平台证书」，用来验证微信支付请求响应体的签名
const platformCertificateFilePath = './src/wechat/apiclient_cert.pem';
const platformCertificateInstance = readFileSync(platformCertificateFilePath);
const wxpay = new Wechatpay({
  mchid,
  serial: merchantCertificateSerial,
  privateKey: merchantPrivateKeyInstance,
  certs: { [platformCertificateSerial]: platformCertificateInstance, },
});


function test() {
  return wxpay.v3.pay.transactions.native.post({
    mchid: 'xxx',
    out_trade_no: 'xxx',
    appid: 'xxx',
    description: 'GPT-3.5体验套餐30次',
    notify_url: 'https://service-32xxuf2e-1316704400.hk.apigw.tencentcs.com/release/pay_notice',
    amount: { total: 600, currency: 'CNY' }
  }).then(({ data: { code_url } }) => {
    //  此处毛也没有
  }).catch(({ response: { status, statusText, data } }) => data).then(data => {
    return JSON.parse(data).code_url  //返回支付链接
  })
}
test().then(data => {
  console.log(data)
})

// 微信支付结果回调密文解密
// const { Aes: { AesGcm } } = require('wechatpay-axios-plugin')
// const secret = 'TOOEg22lkQiLxSBAHu5PEGn6nnuBOPiq'
// const ciphertext = '9VOgFHmRrrnAboS7dnVdOk0rbMLU1b9QyzNfqgbqOAIVWWPm7vdF6CLhwwLXDTZv9icN6Tv71gAi1QNP6NPlYrBN2wsTLVdTwKD2p5D85oOBwO+SV8lRmWM0J9+ON0IcIGd9hurqlkxnDdJpJbWRWclI/dtd4Cn1nFaR7nJC47ZQaA51gAWNHDxEIN0Devk1v3G+I/qm+noYd2hgMfOztWIQujjybmd3sGrdYfftUZHXWsHO5Mcr/i4Du2oERgO515KJVSOdnz/GUeBl9r0Zt6/07jKeTpzVP8/dgo7iLqH4056XCE2vj0YQATR2Z9lb1NCI6Sq/4r9GFo6wJlxc86O2tkNFKSKlidLhlhvxl04wePL/NoPEDM5PiPIafwpPEwQ44dugnYNXKeW+dCLHgk+e6htn1WW7txaI8tUDMc19LL1AI7/odOWDsYkwkDsEeN1nQjg9ESeIG2mKO9tl1/bGMH1OkBF2QH/51jCebdbGjGjWDL/5akO4nDSellOxyb8XlpuEO9vkLtAAVvLOBIGztxLZ6HbyaNVgllHo7cYZrO5AFjSPltSEAshrWxnB9f6e566C'
// const nonce = 'TIWzcQctNipg'
// const associated_data = 'transaction'
// console.log(AesGcm.decrypt(nonce, secret, ciphertext, associated_data))
